package com.luchao.websocketdemo;

import com.luchao.websocketdemo.server.WebSocketServer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.IOException;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = {WebsocketdemoApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) //启动类
public class TestDemo {
    /**
     * 这样不起作用
     */
    @Test
    public void test() {
        System.out.println("xx");
        String message="后台推送";
        String cid="33";
        try {
            WebSocketServer.sendInfo(message,cid);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    @Test
    public void test1(){
//        http://localhost:8080/checkcenter/socket/push/33?message=99
//        httpclient
        String message = "这是后台的发送!";
        String uid = "33";
        String str = "http://localhost:8080/checkcenter/socket/push/"+uid+"?message="+message;
        HttpUtil.HttpGet(str);
    }
}
